package com.shujia.four;

import org.junit.Test;

import java.util.Arrays;

public class ArrayExer1 {

    @Test
    public void test2() {
        int[] arr = new int[3];
        arr[0] = 100;arr[1] = 200;
        arr[2] = 300;
        System.out.println(arr);
        System.out.println(arr[0]);
        System.out.println(arr[1]);
        System.out.println(arr[2]);
        //定义第二个数组指向第一个数组
         int[] arr2 = arr;
         arr2[0] = 111;
         arr2[1] = 222;
         arr2[2] = 333;
         //输出两个数组的名及元素
         System.out.println(arr);
         System.out.println(arr[0]);
         System.out.println(arr2);
         System.out.println(arr2[0]);

    }


    @Test
    public void test1() {
        int[] arr = new int[3];//输出数组名及元素
         System.out.println(arr);
         System.out.println(arr[0]);
         System.out.println(arr[1]);
         System.out.println(arr[2]);
        // 给数组中的元素赋值
         arr[0] = 100;arr[2] = 200;
        // 再次输出数组名及元素
        System.out.println(arr);
        System.out.println(arr[0]);
        System.out.println(arr[1]);
        System.out.println(arr[2]);

    }


}
